<!-- 我的主页 -->
<template>
    <PageWarpper page-name="共享会议室选择">
      <template v-slot:main>
        <view style="margin-top: 136px" v-if="list.length == 0 && currentPage > 1">
          <EmptyCard
            :info="{
              icon: 'empty_icon2',
              iconWidth: '210rpx',
              tip: '暂无订单',
              es: 'No Orders',
              desc: '您还没有此类订单',
            }"
          />
        </view>
        <view class="list">
          <view
            class="list-cell d-flex border-top border-bottom"
            v-for="(item, index) in list"
            :key="index"
          >
            <OrderInfo
              style="flex: 1"
              :btn-name="getBtnName(item)"
              :item-data="item"
              @btnClick="openOpenPage"
            />
          </view>
        </view>
      </template>
    </PageWarpper>
</template>

<script setup>
import { ref, watch } from "vue";
import PageWarpper from "@/components/Layer/PageWarpper.vue";
import OrderInfo from "@/components/List/OrderInfo.vue";
import EmptyCard from "@/pages/empty/Card.vue";
import { getHistoryOrderList } from "@/server/api.js";
import { onLoad } from "@dcloudio/uni-app";
import { openPage } from "@/util/index.js";

let tabIndex = ref(0);

let list = ref([]);
let currentPage = ref(1);
let isLoad = ref(true);

const openOpenPage = item => {
  let url = getBtnName(item)
        ? `/subscribe/roompay?page_type=${item.orderStatus == 1 ? 2 : 1}&id=${item.id}&orderNo=${
            item.orderNo
          }`
        : "";
  openPage(url);
};
let getList = () => {
  getHistoryOrderList({
    current: 1,
    productType: 3,
    size: 100,
  }).then(res => {
	  let successList = [];
	  res.data.records.map(item=>{
	  		  if(item.orderStatus == 1){
	  			  successList.push(item)
	  		  }
	  })
	  list.value = [...successList];
	  isLoad.value = false;
  });
};

function getBtnName(item) {
  if ([2, 3].includes(item.productType) && ![0, 1].includes(item.orderStatus)) {
    return "";
  }
  return item.orderStatus == 0 ? "去支付" : item.orderStatus == 1 ? "检票入场" : "查看详情";
}

onLoad(options => {
  getList();
});
</script>

<style lang="scss" scoped>
#app.content {
  padding-bottom: 0px;
}
.page-name {
  padding-bottom: 40rpx;
}
.list {
  margin-top: 34rpx;
  padding-bottom: 300px;
  .list-cell {
    min-height: 204rpx;
    margin-bottom: 34rpx;
    background-color: #ffffff;
    .thumb {
      width: 154rpx;
      // height: 200rpx;
    }
  }
}
</style>
